#ifndef PITCHFINDER_H
#define PITCHFINDER_H

#include <fftw/fftw++.h>
#include <QFile>
#include <QString>
#include <QAudioInput>
#include <QAudioFormat>
#include <QTimerEvent>
#include <QDataStream>
#include <QTimer>

using namespace fftwpp;

class PitchFinder : public QObject
{
	Q_OBJECT

protected:
	QString fileName;
	QFile dataFile;
	QAudioInput* recorder;
	QAudioFormat format;
	bool recording;

	double sampleTime;
	int frequency;
	int numSamples;
	double dt;
	double df;
	double currMax;

	QDataStream audioData;
	quint16* inputArray;
	Complex* fftArray;
	fft1d Forward;


public:
	PitchFinder(QObject * parent = 0);
	~PitchFinder();

	double GetPitch();
	void Record();
	int GetPeakIndex();
	void SetPitch();


signals:
	void PitchFound(double pitch);

};

#endif // PITCHFINDER_H
